<script type="text/javascript">
  function PrintDiv() {    
           var divToPrint = document.getElementById('print');
           var popupWin = window.open('', '_blank', 'width=800,height=800');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
</script>
<div align="right">
<input type="button" value="Print" onclick="PrintDiv();"></div>
<div class="row-fluid" id="print">
<p align="center"><h3 align="center">
<?php if($sales['invoice_type']=='Retail'){
	echo "Retail Invoice";
	 }else{
	 echo 	"TAX INVOICE";
	} ?></h3></p>
<div class="span1">&nbsp;&nbsp; </div>
<div class="span10">
<div class="row-fluid"> 
<div class="span12">
<table border="1px" width="100%">
		<tr>
            <td><?php  echo "<strong>".$profile['name']."</strong><br>";
	echo $profile['address']."<br>";
	echo $profile['email']."<br>";
	echo $profile['phone_no']."<br>"; ?></td>
		<td>
		<table border="1px" width="100%">
		<tr>
            <td>Invoice No<br><?php echo '<strong>'.$sales['invoice_no'].'</strong>'; ?></td>
			<td>Dated<br><?php echo '<strong>'.$sales['date'].'</strong>'; ?></td>
			<td>Branch<br><?php echo '<strong>'.$this->sales_model->get_branch_name($sales['id_branch']).'</strong>'; ?></td>
		</tr>
		<?php if($sales['invoice_type']!='Retail'){?>
		<tr>
            <td>Company's Tin No<br><?php echo '<strong>'.$profile['tin_no'].'</strong>'; ?></td>
			<td>Buyers's Tin No<br><?php echo '<strong>'.$customer['tin_no'].'</strong>'; ?></td>
		</tr>
		<?php }else{?>
		<tr>
            <td colspan="3">Company's Tin No<br><?php echo '<strong>'.$profile['tin_no'].'</strong>'; ?></td>
		</tr>
		<?php } ?>
		</table>
		</td>
		</tr>
		<tr>
		
            <td><h4><b>Buyer Details</h4><?php 
			echo "--------";
	 ?></td>
				<td>
		<table border="1px" width="100%">
		<tr>
            <td>Billed By<br><?php echo '<strong>'.$sales_man.'</strong>'; ?></td>
			<td>Transaction Type<br><?php echo '<strong>'.$sales['transaction_type'].'</strong>'; ?></td>
	
		</tr>
		<tr>
            <td>Despatched Through<br><?php echo '<strong>'.$sales['transport_name'].'</strong>'; ?></td>
			<td>Despatched Amount<br><?php echo '<strong>'.$sales['transport_amt'].'</strong>'; ?></td>
		</tr>

		
		</table>
		</td>

		</tr>

</table>
</div>
</div>
<br>
<div class="row-fluid">
<div class="span12" >
<table border="1px" width="100%">
	<thead>
    <tr>
		<th>Product Name</th>
		<th>Quantity</th>
        <th>Rate</th>
        <th>Amount</th>
        <th>Tax</th>
        <th>Discount</th>
		<th>Toatal Price</th>	
	</tr>
    </thead>
	<?php foreach ($products as $product):?>
		<tr>
			<td><?php  echo $this->purchase_model->get_product_details($product->id_product); ?></td>
			<td><?php  echo $product->quantity; ?></td>
            <td><?php  echo $product->rate; ?></td>
            <td><?php  echo $product->amount; ?></td>
			<td><?php  echo $product->discount; ?>%</td>
			<td><?php  echo $product->tax; ?>%</td>
			<td><?php  echo $product->total; ?></td>
		</tr>
	<?php endforeach;?>
</table>
</div>
</div>
<hr>
<div class="row-fluid">
<div class="span12">
<table width="100%">
<tr><td width="50%">
<table  width="100%">
	<tr><td width="100%"  ><div onclick="show_tb_row()"  id="text"> </div>
		<textarea id="tb_row" cols="30" onblur="write_text(this.value)" rows="5"></textarea>
	</td></tr>
</table>
</td>

<td width="50%" ><table border="1px" width="100%">
			<tr>
			<td><b>Total Amount</b><br>(Without Tax And Discount)</td><td><?php  echo $sales['amount']; ?></td>
			</tr>
          	<tr><td><b>Total Discount</b></td><td><?php  echo $sales['total_disc']; ?></td>
		   	</tr>
		   	<tr>
		    <td><b>Total Excise Duty</b></td><td><?php  echo $sales['total_excise']; ?></td>
          	</tr> 
			<tr>
		    <td><b>Total Tax</b></td><td><?php  echo $sales['total_tax']; ?></td>
          	</tr> 
			<tr>
			<td><b>Total Price</b></td><td><?php  echo $sales['total_price']; ?></td>
			</tr>
			

</table>
</td></tr>
</table>
<hr>



 </div>
 
</div>
<br>
<hr>
<div class="row-fluid">
<div class="span12">
<table>
<tr>
<td width="60%"><b>Declarion:</b><br>We declare that this invoice shows the actual price of the goods described and that all particulars are true and correct</td>
<td><p align="right"><b>For <?php echo  $profile['name'];?></b></p><br>
<br>
<br>
<p align="right"><b>(Authorized Signatory)</b></p>
</td>

</tr>
</table>
</div>
</div>

</div>
<div class="span1">&nbsp;&nbsp; </div>
</div>